﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SimpleFileManager
{
    public partial class FormNameInput : Form
    {
        public event ConfirmEventHandler OnConfirm;

        public FormNameInput()
        {
            InitializeComponent();
        }

        public FormNameInput(string name)
            : this()
        {
            txtName.Text = name;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
                if (OnConfirm != null)
                {
                    OnConfirm(this, new ConfirmEventArgs(txtName.Text));
                }
                txtName.Text = "";
                Close();
        }

        private void FormNameInput_Load(object sender, EventArgs e)
        {
            
        }
    }


    public class ConfirmEventArgs : EventArgs
    {
        private string _name;

        public string Name
        {
            get
            {
                return _name;
            }
        }

        public ConfirmEventArgs(string name)
        {
            _name = name;
        }
    }

    public delegate void ConfirmEventHandler(object sender, ConfirmEventArgs e);
}
